package com.teamwe.movecard.domain;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.stereotype.Component;

import javax.persistence.*;

@Component
@Data
@Entity
@ApiModel(description = "用户对象")
@Table(name = "user")
public class User {
    @Id
    @ApiModelProperty(notes = "微信用户唯一标识", name = "openId")
    private String mpOpenId;
    //昵称
    @ApiModelProperty(notes = "微信用户昵称", name = "nickName")
    private String nickName;
    //用户头像链接
    @ApiModelProperty(notes = "微信用户头像URL链接", name = "userAvatarUrl")
    private String userAvatarUrl;
    @OneToOne(mappedBy = "user")
    @JsonIgnore
    private Score score;
    //临时登陆凭证
    @Transient
    @JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
    @ApiModelProperty(notes = "临时登陆凭证，只有微信授权登录，提交数据时才需要用到", name = "js_code")
    private String js_code;
    //密文
    @Transient
    @JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
    @ApiModelProperty(notes = "微信用户敏感信息加密字符串，只有微信授权登录，提交数据时才需要用到", name = "encryptedData")
    private String encryptedData;
    //初始向量
    @Transient
    @JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
    @ApiModelProperty(notes = "加密算法初始向量，只有微信授权登录，提交数据时才需要用到", name = "iv")
    private String iv;

    @Override
    public String toString() {
        return "User{" +
                "openId='" + mpOpenId + '\'' +
                ", nickName='" + nickName + '\'' +
                ", userAvatarUrl='" + userAvatarUrl + '\'' +
                '}';
    }
}
